package crp.services.api.graphql.models;

import com.fasterxml.jackson.annotation.JsonIgnore;
import crp.core.course.domain.models.CourseAttributesEntity;
import crp.core.course.domain.models.CourseSourceType;
import com.qwlabs.storage.models.StorageObject;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import org.eclipse.microprofile.graphql.Type;

@Type("CourseAttributes")
@Builder
@Getter
@AllArgsConstructor
public class CourseAttributesPayload {
    @JsonIgnore
    private final String courseId;
    private final CourseSourceType sourceType;
    @JsonIgnore
    private final StorageObject cover;
    @JsonIgnore
    private final String openDepartmentId;
    @JsonIgnore
    private final String academicTermId;


    public static CourseAttributesPayload empty() {
        return CourseAttributesPayload.builder()
                .courseId("")
                .build();
    }

    public static CourseAttributesPayload of(CourseAttributesEntity entity) {
        return CourseAttributesPayload.builder()
                .courseId(entity.getCourseId())
                .sourceType(entity.getSourceType())
                .cover(entity.getCover())
                .openDepartmentId(entity.getOpenDepartmentId())
                .academicTermId(entity.getAcademicTermId())
                .build();
    }
}
